package com.gzhryc.system.dao;

import java.sql.SQLException;
import java.util.List;

import com.gzhryc.jdbc.BaseDao;
import com.gzhryc.jdbc.Query;
import com.gzhryc.system.dao.db.Manager;

/**
 * 用户数据访问
 * @author 张浩
 * @version 0.1.0
 */
public class ManagerDao extends BaseDao<Manager>{

	public ManagerDao(String jdbcKey) {
		super(jdbcKey);
	}

	public List<Manager> findByRoleId(Long roleId,Integer pageNo,Integer pageLimit) throws SQLException{
		String sql = "SELECT t.* FROM sys_manager t"
				+ " INNER JOIN sys_manager_role t1 ON t1.manager_id = t.id"
				+ " WHERE t1.role_id = ?";
		Query query = new Query(sql);
		query.getParams().setObject(roleId);
		query.setPageNo(pageNo);
		query.setPageLimit(pageLimit);
		return this.jdbcHelper.find(query, Manager.class);
	}
}
